package com.example.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.entity.Rule;
import com.example.entity.Scholarship;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface RuleMapper  extends BaseMapper<Rule> {

    @Select("select * from rule where rule_name like concat('%',#{rule_name},'%') and rule_deleted = 0 limit #{start},#{pageSize}")
    List<Rule> selectPage(@Param("rule_name") String rule_name, @Param("start")Integer start, @Param("pageSize")Integer pageSize);


    @Select("select count(*) from rule where rule_name like concat('%',#{rule_name},'%') and rule_deleted = 0 " )
    Integer selectTotal(@Param("rule_name") String rule_name);

   /* @Insert("insert into rule(rule_name，rule_grade,rule_year,rule_info) values(#{rule_name},#{rule_grade},#{rule_year},#{rule_info})")
    int insert (Rule rule);*/

    @Update("update rule set rule_name =#{rule_name},rule_grade =#{rule_grade},rule_year =#{rule_year},rule_info =#{rule_info} where rule_no =#{rule_no}and rule_deleted = 0 ")
    void update(Rule rule);

   /* @Delete("delete from rule where rule_no = #{rule_no}")
    void delete (Integer rule_no);*/

    @Update("update Rule set rule_deleted=1 where rule_no=#{ rule_no} and rule_deleted=0")
     void delete (Integer  rule_no);


}

